package com.cunshe.service;

import com.cunshe.dao.SecondScreenDao;
import com.cunshe.domain.SecondScreen;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 第二屏内容
 * @author
 */
@Service
public class SecondScreenService {

    @Autowired
    private SecondScreenDao secondScreenDao;

    @Transactional(rollbackFor = Exception.class)
    public int insert(SecondScreen record) {
        return secondScreenDao.insert(record);
    }

    @Transactional(rollbackFor = Exception.class)
    public int delete(Long id) {
        return secondScreenDao.delete(id);
    }

    @Transactional(rollbackFor = Exception.class)
    public int update(SecondScreen record) {
        return secondScreenDao.update(record);
    }

    public List<SecondScreen> top(int top, int type) {
        PageHelper.startPage(0, top);
        return secondScreenDao.list(SecondScreen.builder().type(type).build());
    }

    public List<SecondScreen> list(SecondScreen record) {
        return secondScreenDao.list(record);
    }

}